package com.springboot.ding.monitor;

import com.springboot.ding.monitor.message.TextMessage;

/**
 * @description:
 * @author: zyj
 * @create: 2020-07-23 18:01
 **/
public class MonitorTask implements Runnable {

    public MonitorTask(){}

    private BaseMessageInte baseMessage;

    public MonitorTask(BaseMessageInte baseMessage){
        this.baseMessage = baseMessage;
    }

    @Override
    public void run() {
        if(null == baseMessage){
            return;
        }

        /**文本消息*/
        if(baseMessage instanceof TextMessage){
            TextMessage textMessage = (TextMessage) baseMessage;
            String jsonString = baseMessage.coverMessage();
            String url = MonitorUtil.getConfig().getUrl()+"?access_token="+textMessage.getAccessToken()+"&timestamp="+textMessage.getTimestamp()+"&sign="+textMessage.getSign();
            SendMessage.sendPostByJsonString(url,  jsonString);
        }
    }



}
